import { IDefault } from './IDefault';

export class NumberDefault implements IDefault<number> {
  private mJsonValue: ESObject

  constructor(jsonValue: ESObject) {
    this.mJsonValue = jsonValue
  }

  defaultValue(): number {
    return 0
  }

  asTargetType(): number {
    let asValue = Number(this.mJsonValue).valueOf()
    if (asValue.toString() =="NaN" ) {
      return 0
    } else {
      return asValue
    }
  }
}